package net.wanglu.www.zzz.main;

import java.util.ArrayList;
import java.util.Iterator;

public class DataBufferPoolManager {

	private ArrayList<DataBufferPool> poolList = new ArrayList<DataBufferPool>(4);
	
	public DataBufferPool borrowAPool() {
		DataBufferPool dp = new DataBufferPool();
		poolList.add(dp);
		return dp;
	}
	
	public void returnAPool(DataBufferPool dp) {
		if ( poolList.contains(dp)) {
			dp.finishPool();
		}
	}
	
	public void releasePools() {
		for (Iterator<DataBufferPool> itr = poolList.iterator(); itr.hasNext(); ) {
			DataBufferPool dp = itr.next();
			dp.finishPool();
		}		
	}
}
